home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #1
/
Amiga Plus 1995 #1.iso
/
fish-disketten
/
fish_811-820
/
d811
/
bsh
/
pr
< prev
next >
Wrap
Text File
|
1994-12-13
|
1KB
|
33 lines
local j i nl each pad tmp num=0 a[999] across=0 IFS="\n" ml
if #argv>1
if left(argv[1],1)=='-'
across=right(argv[1],strlen(argv[1])-1)
endif
endif
while num<999;read a[$num];if eof(0);break;endif;num++;endwhile
if across==0
i=0,ml=0
repeat num 'if (j=strlen(a[i]))>ml;ml=j;endif;i++'
across=max(1,(width+2)/(ml+2))
endif
each=(width+2)/across,nl=(num+across-1)/across,i=0
pad=left(" ",each)
while i<nl
j=i++
repeat (num-j-1)/nl 'tmp=left(cat(a[j],pad),each);echo -n "$tmp";j+=nl'
echo $a[$j]
endwhile
return
## pr - a program to print things in columns. This is just a toy
# version of the real pr program; it can only handle 999 items and
# has no options other than the number of columns. Pr gets its
# input from the standard-input and writes to standard-output.
# pr [-ncol]
#
# The code for pr is highly compressed to improve speed (interpretive
# execution speed is dependent on the size of the source).
# Pr is presented as is; no warrantee is either expressed or implied
# as to it's suitability to any purpose whatsoever. You assume all the
# risk for all damage, even if caused by a defect in the software,
# no matter how awful.